#ifndef _NE_NODE_ANIMATION_TRACK_H_
#define _NE_NODE_ANIMATION_TRACK_H_

#include <common/SharedPtr.h>
#include <mathematics/Node.h>
#include <animation/AnimationTrack.h>
#include <animation/TransformKeyFrame.h>

namespace ne
{
    class NEAPI NodeAnimationTrack : public AnimationTrack
    {
        public:
            NodeAnimationTrack(Animation *parent, const uint16_t handle, Node *node=0);

            virtual TransformKeyFrame* createTransformKeyFrame(const real time);

            virtual void setAssociatedNode(Node *node);

            virtual Node* getAssociatedNode() const;

            virtual TransformKeyFrame* getTransformKeyFrame(const size_t index) const;

            virtual void getKeyFrameAtTime(const real time, KeyFrame &keyFrame) const;

            virtual void getTransformKeyFrameAtTime(const real time, TransformKeyFrame &keyFrame) const;

            virtual void setUseShortestRotationPath(const bool shortestPath);

            virtual bool getUseShortestRotationPath() const;

            virtual void apply(const real time, const real weight=1.0f, const real scaleU=1.0f);

            virtual void applyToNode(Node *node, const real time, const real weight=1.0f, const real scaleU=1.0f);

            virtual bool hasNonZeroKeyFrames() const;

            virtual void optimise();

            virtual void _keyFrameDataChanged() const;

            virtual ~NodeAnimationTrack();

        protected:
            virtual KeyFrame* _createKeyFrameImpl(const real time);

            virtual void _buildInterpolationSplines() const;

        private:
            NodeAnimationTrack();

            NodeAnimationTrack(const NodeAnimationTrack &);

            NodeAnimationTrack& operator = (const NodeAnimationTrack &);

        protected:
            Node *mpTargetNode;
            bool mUseShortestRotationPath;
            mutable bool mSplineBuildNeeded;
    };

    typedef SharedPtr<NodeAnimationTrack> NodeAnimationTrackPtr;

    typedef std::map<uint16_t, NodeAnimationTrackPtr> NodeAnimationTrackMap;
    typedef NodeAnimationTrackMap::iterator NodeAnimationTrackMapIterator;
    typedef NodeAnimationTrackMap::const_iterator NodeAnimationTrackMapConstIterator;
}

#endif
